package com.xmhmyh.generalframework.common.conversion;

import com.xmhmyh.generalframework.common.enums.BaseEnums;
import com.xmhmyh.generalframework.common.vo.SelectVO;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 于丁
 * 枚举转换为前端选择
 * @DateTime: 2020/7/29 9:21 上午
 */
public class Enum2SelectVOConversion {

    public static  <T extends BaseEnums> List<SelectVO> conversion(Class<T> enumClass) {
        List<SelectVO> selectVOList = new ArrayList<>();
        for (T each : enumClass.getEnumConstants()) {
            selectVOList.add(new SelectVO(each.getLabel(), String.valueOf(each.getValue())));
        }
        return selectVOList;
    }
}
